<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        ul {
            list-style: none;
            border: 1px solid black;
            width: 40px;
            margin-top: 5px;
            text-align: center;
        }

        ul li {
            height: 25px;
            line-height: 25px;
        }
        ul li:hover {
            background-color: brown;
            color: #fff;
        }

        .box {
            width: 100px;
            height: 200px;
            margin: 10px auto;
        }

        .remo {
            border-top: 1px solid black;
        }
    </style>
</head>

<body>
    <div class="box">
        <button class="btn">输入法</button>
        <ul class="ul">
            <li>简写</li>
            <li>拼音</li>
            <li class="remo">关闭</li>
        </ul>
    </div>
</body>
<script>
    var btn = document.querySelector('.btn')
    var ul = document.querySelector('.ul')
    var remo = document.querySelector('.remo')
    var li = document.querySelectorAll('.ul li')
    // 关闭功能
    remo.onclick = function () {
        ul.style = "display:none"
    }

    btn.onclick = function () {
        if (ul.style.display != "block") {
            ul.style.display = "block"
        } else {
            remo.onclick()
        }
    }

</script>

</html>